<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class UserPostRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|alpha_dash|max:18|min:6',
            'password' => 'required|alpha_num|max:18|min:6',
            'repassword' => 'required|same:password',
            'pic' => 'image',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'username.required' => '用户名不能为空',
            'username.alpha_dash'  => '用户名需仅包含字母、数字、破折号（ - ）以及下划线（ _ ）',
            'username.max'  => '请输入6-18位用户名',
            'username.min'  => '请输入6-18位用户名',
            'password.required'  => '密码不能为空',
            'password.alpha_num'  => '密码需仅包含字母、数字',
            'password.max'  => '请输入6-18位密码',
            'password.min'  => '请输入6-18位密码',
            'repassword.required'  => '确认密码不能为空',
            'repassword.same'  => '两次密码不一致',
            'pic.image'  => '文件格式不正确',

        ];
    }
}
